/**
 * Vue Router 路由配置文件
 * 功能：配置前端路由，管理页面导航
 * 作者：AI Assistant
 * 创建时间：2025-01-15
 */
import { createRouter, createWebHistory } from 'vue-router'
import MainContent from '../components/MainContent.vue'
import TestAPI from '../views/TestAPI.vue'

const routes = [
  {
    path: '/',
    name: 'Home',
    component: MainContent,
    meta: {
      title: 'MetasoCreator - 智能搜索与问答平台'
    }
  },
  {
    path: '/chat',
    name: 'Chat',
    component: MainContent,
    meta: {
      title: 'MetasoCreator - 智能对话'
    }
  },
  {
    path: '/search',
    name: 'Search',
    component: MainContent,
    meta: {
      title: 'MetasoCreator - 智能搜索'
    }
  },
  {
    path: '/reader',
    name: 'Reader',
    component: MainContent,
    meta: {
      title: 'MetasoCreator - 网页阅读器'
    }
  },
  {
    path: '/test-api',
    name: 'TestAPI',
    component: TestAPI,
    meta: {
      title: 'MetasoCreator - API测试'
    }
  }
]

// 创建路由实例
const router = createRouter({
  history: createWebHistory(),
  routes
})

// 路由守卫 - 设置页面标题
router.beforeEach((to, from, next) => {
  // 设置页面标题
  if (to.meta.title) {
    document.title = to.meta.title
  }
  next()
})

export default router